package cn.pfcg.rally.util;

import java.lang.reflect.InvocationTargetException;
import java.util.Calendar;

import cn.pfcg.rally.domain.bean.Question;
import cn.pfcg.rally.ui.web.vo.QuestionView;

import org.apache.commons.beanutils.BeanUtils;

public class QuestionBoToVo {

	public void BOToVo(Question question, QuestionView questionView) {

		try {
			BeanUtils.copyProperties(questionView, question);
			questionView.setMakeTime(parseTime(question.getMakeTime()));
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}

	}

	public String parseTime(Calendar calendar) {
		String date = null;
		int year = calendar.get(Calendar.YEAR);
		int month = calendar.get(Calendar.MONTH) + 1;
		int day = calendar.get(Calendar.DAY_OF_MONTH);
		date = year + "-" + month + "-" + day;
		return date;
	}
}
